package com.gzhryc.common.config;

import org.apache.commons.lang3.StringUtils;

public class DefaultEnum {

	public static enum Sex {

		Female(0, "女"), Male(1, "男");

		private Integer index;
		private String note;

		Sex(Integer index, String note) {
			this.index = index;
			this.note = note;
		}

		public Integer index() {
			return index;
		}

		public String note() {
			I18nTools.I18n i18n = I18nTools.getCurrentI18n();
			if (i18n != null) {
				return i18n.get(this.name(), note);
			}
			return note;
		}

		public static String note(Integer index) {
			return note(index, null);
		}

		public static String note(Integer index, String defaultValue) {
			if (index != null) {
				Sex[] temp = Sex.values();
				for (int i = 0; i < temp.length; i++) {
					Sex item = temp[i];
					if (item.index.equals(index)) {
						return item.note();
					}
				}
			}
			return defaultValue;
		}

		public static String note(String index) {
			if (StringUtils.isNotBlank(index) && StringUtils.isNumeric(index)) {
				Integer num = Integer.valueOf(index);
				Sex[] temp = Sex.values();
				for (int i = 0; i < temp.length; i++) {
					Sex item = temp[i];
					if (item.index.equals(num)) {
						return item.note();
					}
				}
			}
			return index;
		}

		public static Integer index(String note) {
			Sex[] temp = Sex.values();
			for (int i = 0; i < temp.length; i++) {
				Sex item = temp[i];
				if (item.note.equals(note)) {
					return item.index;
				}
			}
			return null;
		}
	}

	public static enum Status {

		Usable(1, "可用"), Unusable(2, "禁用");

		private Integer index;
		private String note;

		Status(Integer index, String note) {
			this.index = index;
			this.note = note;
		}

		public Integer index() {
			return index;
		}

		public String note() {
			I18nTools.I18n i18n = I18nTools.getCurrentI18n();
			if (i18n != null) {
				return i18n.get(this.name(), note);
			}
			return note;
		}

		public static String note(Integer index) {
			Status[] temp = Status.values();
			for (int i = 0; i < temp.length; i++) {
				Status item = temp[i];
				if (item.index.equals(index)) {
					return item.note();
				}
			}
			return null;
		}
	}

	public static enum AuditStatus {

		WaitAudit(1, "等待认证"), AuditPass(2, "认证通过"), AuditFail(3, "认证不通过");

		private Integer index;
		private String note;

		AuditStatus(Integer index, String note) {
			this.index = index;
			this.note = note;
		}

		public Integer index() {
			return index;
		}

		public String note() {
			I18nTools.I18n i18n = I18nTools.getCurrentI18n();
			if (i18n != null) {
				return i18n.get(this.name(), note);
			}
			return note;
		}

		public static String note(Integer index) {
			AuditStatus[] temp = AuditStatus.values();
			for (int i = 0; i < temp.length; i++) {
				AuditStatus item = temp[i];
				if (item.index.equals(index)) {
					return item.note();
				}
			}
			return null;
		}
	}

	public static enum Weeks {
		
		Monday(1, "周一"), Tuesday(2, "周二"), Wednesday(3, "周三"), Thursday(4, "周四"), Friday(5, "周五"), Saturday(6, "周六"), Sunday(0, "周日");

		private Integer index;
		private String note;

		Weeks(Integer index, String note) {
			this.index = index;
			this.note = note;
		}

		public Integer index() {
			return index;
		}

		public String note() {
			I18nTools.I18n i18n = I18nTools.getCurrentI18n();
			if (i18n != null) {
				return i18n.get(this.name(), note);
			}
			return note;
		}

		public static String note(Integer index) {
			Weeks[] temp = Weeks.values();
			for (int i = 0; i < temp.length; i++) {
				Weeks item = temp[i];
				if (item.index.equals(index)) {
					return item.note();
				}
			}
			return null;
		}
	}
}
